#include "request_reply.h"
#include "rpc.h"
#include "Bank.h"

using namespace dds::domain;
using namespace dds::sub;
using namespace dds::pub;
using namespace dds::rpc;
using namespace dds;

void bank_test()
{
  // Creating a service
  DomainParticipant *dp = 0;
  RPCRuntime rpcruntime(dp);
  
  rpcruntime.create_service<Bank::CheckingAccount>(
    *new mybank::MyCheckingAccountImpl(), // implementation
    "CheckingAccount",                    // Service name
    "My1234CheckingAccount");             // Instance name
    rpcruntime.start_service_processing();

  // Creating a client
  ServiceProxy<Bank::CheckingAccount> cap
  = rpcruntime.create_client<Bank::CheckingAccount>(
  "CheckingAccount",          // Service name
  "My1234CheckingAccount");   // Instance name

  cap.order_checks(50, Bank::Address("232 E. Java Dr."));

  ServiceProxy<Bank::Account> acc1 = cap;
  acc1.deposit(100);

  // Creating a client that uses services polymorphically
  ServiceProxy<Bank::Account> acc2
    = rpcruntime.create_client<Bank::Account>(
          "CheckingAccount",          // Service name
          "My1234CheckingAccount");   // Instance name

  acc2.deposit(100);

}

int main(void)
{

  return 0;
}